using System;
using System.Collections.Generic;
using System.Web.Mvc;
using Toast.ContentTypes;
using Toast.Core;

namespace Toast.Attributes
{
    [Obsolete("Use Content Attribute")]
    [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
    public class LocalFileScriptAttribute : ActionFilterAttribute
    {
        readonly InjectAt _injectAt;

        protected LocalFileScriptAttribute(InjectAt injectAt)
        {
            _injectAt = injectAt;
        }

        public LocalFileScriptAttribute(InjectAt injectAt, IEnumerable<string> scriptPaths)
            : this(injectAt)
        {
            foreach (var scriptPath in scriptPaths)
            {
                RequestContentTable.Contents.Add(LocalJavaScriptFile.FromPath(scriptPath));
            }
        }

        public LocalFileScriptAttribute(InjectAt injectAt, string scriptPath)
            : this(injectAt)
        {
            RequestContentTable.Contents.Add(LocalJavaScriptFile.FromPath(scriptPath));
        }
    }
}